<template>
 <view class="main">
  <view class="part1">
	<view class="part1-1">选择时间</view> 
	<view class="part1-2">订单号：{{oinfo.ordersn}}</view> 
  </view> 
  <view class="ztimetc">
	 <view class="timec topc1" @click="ztime(1)">
	  <image src="https://ppp.new.zeroitem.cn/ppp/clock.png" class="img8"></image>
	   <view class="timec1" :class="[{'timecur': ztype==1}]">一小时（+97元）</view> 
	   <view class="qun" :class="[{'cur3': ztype==1}]"></view>
	</view> 
	 
	 <view class="timec" @click="ztime(2)">
	  <image src="https://ppp.new.zeroitem.cn/ppp/clock.png" class="img8"></image>
	   <view class="timec1" :class="[{'timecur': ztype==2}]">二小时（+194元）</view>  
	   <view class="qun" :class="[{'cur3': ztype==2}]"></view> 
	</view> 
		 
	 <view class="timec" @click="ztime(3)">
	  <image src="https://ppp.new.zeroitem.cn/ppp/clock.png" class="img8"></image>
	   <view class="timec1" :class="[{'timecur': ztype==3}]">三小时（+291元）</view> 
	   <view class="qun" :class="[{'cur3': ztype==3}]"></view>
	</view> 		 
		 
	 
  </view>
  <view class="part4" @click="qrzj">确认追加</view>

 </view>
</template>
<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		toLogin
	} from '@/utils/login'
	import {
	   getOrderDetail,ztime
	} from '@/api/ppp'	
	import {
		loadingFun,
		menuJump
	} from '@/utils/tools'
export default {
	    data() {
	        return {
             zt:0,
			 oinfo:[],
			 ztype:0
	        }
	    },
		onShow(){
	
		},
		onLoad(options){
		 var oid=options.oid;
		 this.oid=oid;
		 this.getOrderDetail(oid);
		},
	    methods: {
		async getOrderDetail(oid){
			  const{
			  code,
			  msg,
			  data
			  }= await getOrderDetail(oid);
			  this.oinfo=data; 
			  var zt=parseInt(data.step)-1;
			  this.zt=zt;
		 },
		 ztime(ztype){
		   this.ztype=ztype; 
		 },
		 async qrzj(){
		   var oinfo=this.oinfo;
		   var that=this;
		   if(oinfo.persion_pingjia!=1){
			uni.showToast({title:'无权限操作',icon:"none"});
			return false;
		   }
		   if( this.zt<0){
			uni.showToast({title:'当前订单无法追加时间',icon:"none"});
			return false;
		   }
		   if(this.ztype==0){
			uni.showToast({title:'请选择您要追加的时间',icon:"none"});
			return false;   
		   }
		   const{
		   code,
		   msg,
		   data
		   }= await ztime({oid:this.oid,ztype:this.ztype});
		   if(data.suc==1){
			uni.showToast({title:'追加成功',icon:"none"}); 
			setTimeout(function(){
			 uni.navigateTo({
			 	url:"/pages/ppp/order/order1?oid="+that.oid
			 })	
			},2000)
		   }else{
			uni.showToast({title:data.msg,icon:"none"});
			return false;   
		   }
		 }
		 
		 
	    }
	}
</script>

<style>
 @import "./ztime.css";	
</style>
